import { FileManageModel } from '@/network'
import { IAsideTitle } from '@/typing'

interface IUseData {
  asideActive: number
  asideList: IAsideTitle[]
}

interface IUseFileMange {
  getAsideList: (data: IUseData) => any
  useHandleClickLi: (path: string, index: number, data: IUseData, router: any) => void
}

const http = new FileManageModel()

function useFileManage(): IUseFileMange {
  async function getAsideList(data: IUseData) {
    data.asideList = await http.getAsideList()
  }

  function useHandleClickLi(path: string, index: number, data: IUseData, router: any): void {
    data.asideActive = index
    router.push(path)
  }

  return {
    // 获取左侧路由列表
    getAsideList,
    // 左侧按钮点击
    useHandleClickLi
  }
}

export { useFileManage }
